<html>
<head>
<title>Login</title>
	<link rel="stylesheet" type="text/css" href="<?php echo base_url(); ?>public/css/bootstrap-theme.min.css" >
	<link rel="stylesheet" type="text/css" href="<?php echo base_url(); ?>public/css/bootstrap.min.css">
	<link rel="stylesheet" type="text/css" href="<?php echo base_url(); ?>public/css/style.css">
	<script charset="utf-8" src="<?php echo base_url(); ?>public/other/kindeditor/kindeditor-all-min.js"></script>
	<script charset="utf-8" src="<?php echo base_url(); ?>public/other/kindeditor/lang/zh-CN.js"></script>
	<script type="text/javascript" src="<?php echo base_url();?>public/js/jquery.min.js"></script>
	<script type="text/javascript" src="<?php echo base_url();?>public/js/jquery.upload.js"></script>
</head>
</head>
<body >
		<script>
			var editor;
			KindEditor.ready(function(K) {
				editor = K.create(["#content"]);
				})
				
		</script>
		<style>
			.c{
				width: 500px;
			}
		</style>
	<div class="container" >
		<div class="page-header">
		 <h1><?=$title;?><small>文章</small></h1>
		</div>
		<div class="row">		
			<div class="col-md-9 col-md-offset-2">
			
				 
				  <div class="panel-body">
						<form action="" method="POST" class="form-horizontal">
						    <div class="form-group">
							    <label class="col-md-2 control-label">文章</label>
							    <div class="col-md-10">
									<input type="text" class="form-control" name="title" value="<?php echo set_value('title',$article->title);?>" size="50" /><?php echo form_error('title'); ?>
								</div>
							</div>
							<div class="form-group">
							    <label class="col-md-2 control-label">摘要</label>
							    <div class="col-md-10">
									<textarea class="form-control" name="desc"><?php echo set_value('desc',$article->desc);?></textarea>
									<?php echo form_error('desc'); ?>
								</div>
						    </div>
						    <div class="form-group">
							     <label class="col-md-2 control-label">内容</label>
							     <div class="col-md-10">
									<textarea class="form-control" id="content" name="content"><?php echo set_value('content',$article->content);?></textarea>
									 <?php echo form_error('content'); ?>
								</div>						    </div>
						    <div class="form-group">
							     <label class="col-md-2 control-label">图片</label>
							     <div class="col-md-5">
							     <input type="text" class="form-control" name="img" id="img" value="<?php echo set_value('img',$article->img);?>" size="50" /><a href="#" id='upload'>上传文件</a><?php echo form_error('img'); ?>
								</div>
								<div id="preview"  class="col-md-5"></div>
						    </div>	    
						    <div class="form-group">
							     <label class="col-md-2 control-label">分类</label>
							     <div class="col-md-10">
									<select name="catalog_id" class="form-control">
										<option value="">请选择一个分类</option>
									<?php
										foreach ($catalog as $c)
										{
									?>
											<option  value="<?php echo $c->id; ?>" <?php echo set_select('catalog_id',$c->id,$c->id==$article->catalog_id);?>><?php echo $c->name;?></option>
									<?php
										}
									?>	
										</select>
										<?php echo form_error('catalog_id'); ?>
									</div>
						    </div>
						    <div class="form-group">
							    <label class="col-md-2 control-label"></label> 
							    <div class="col-md-10">       
						   		<button type="submit" class="btn btn-success ">提交
						    	</button>
						    	</div>
						    </div>
						</form>
				    </div>			
			</div>
		</div>
	</div>
 
</body>
<script type="text/javascript">
$('#upload').click(function(){
	$.upload({
        // 上传地址
        url: '<?php echo site_url("/admin/util/upload")?>', 
        // 文件域名字
        fileName: 'file', 
        // 其他表单数据
        dataType: 'text',
        // 上传之前回调,return true表示可继续上传
        onSend: function() {
                return true;
        },
        // 上传之后回调
        onComplate: function(data) {
        	//alert(data);
        	if(data.indexOf("uploads")!=-1){
        		$('#img').val(data);
                $('#preview').html('<img style="height:89px" src="<?php echo base_url().'public/';?>'+data+'"/>');
        	}else{
        		alert(data);
        	}      
        } 	
	});
})

</script>
</html>
